package chapter5.java;

/**
 * @Author juzipi
 * @Date 2021/5/17 13:20
 * @Info 解析调用中非虚方法和虚方法的测试
 */
public class Son extends Father {

    public Son(){
        super();
    }

    public Son(int age){
        this();
    }

    //不是重写的父类的方法
    public static void showStatic(String str){
        System.out.println("son"+str);
    }

    private void showPrivate(String str){
        System.out.println("son private"+str);
    }

    public void show(){
        //invokestatic,非虚方法
        showStatic("你好啊");
        super.showStatic("大家好啊");
        showPrivate("hello!");
        super.showCommon();

        //invokevirtual虚方法
        //因为此方法声明有final，不能被子类重写，所以也认为此方法是非虚方法
        showFinal();
        showCommon();
        info();

        MethodInterface in = null;
        //invokeinterface
        in.methodA();
    }

    public void info(){

    }

    public void display(Father father){
        father.showCommon();
    }

    public static void main(String[] args) {
        var name = "你好";
        var age = "asd";
        System.out.println(name.equals(age));

        Son son = new Son();
        son.show();


    }

}

interface MethodInterface{
    void methodA();
}


class Father{
    public Father(){

    }

    public static void showStatic(String str){
        System.out.println("father" + str);
    }

    public final void showFinal(){
        System.out.println("father show final");
    }

    public void showCommon(){
        System.out.println("father 普通方法");
    }

}